/**
 * @ Author 何涛
 * @ Date 2016/02/19 12:57:32
 */
tyNamespace.WaittingLayer = tyNamespace.TyModelLayer.extend({
    position: null,

    ctor: function (opacity, position) {
        if (position == null )
            position = cc.p(640, 360);

        this.position = position;

        if (opacity != null)
            this._super(opacity);
        else
            this._super();
    },

    onEnter: function () {
        this._super();

        //等待中
        var armature = new ccs.Armature("loading_001u");
        armature.getAnimation().playWithIndex(0);
        armature.getAnimation().setSpeedScale(1);
        armature.setScale(1);
        armature.setAnchorPoint(0.5, 0.5);
        armature.setPosition(this.position.x, this.position.y);
        this.addChild(armature);
    }
});

tyNamespace.addWaitLayer = function (position) {
	var runningScene = cc.director.getRunningScene();
	var waitingLayer = runningScene.getChildByName(gpNamespace.WAIT);
	if(!waitingLayer){
		waitingLayer = new tyNamespace.WaittingLayer(position);
		waitingLayer.setName(gpNamespace.WAIT);
		runningScene.addChild(waitingLayer, 111);
	}
};

tyNamespace.removeWaitLayer = function () {
	var runningScene = cc.director.getRunningScene();
	var waitingLayer = runningScene.getChildByName(gpNamespace.WAIT);
	waitingLayer && waitingLayer.removeFromParent(true);
};

tyNamespace.WaittingLayer_CanClick = cc.LayerColor.extend({
	onEnter: function () {
		this._super();

		//等待中
		var armature = new ccs.Armature("loading_001u");
		armature.getAnimation().playWithIndex(0);
		armature.getAnimation().setSpeedScale(1);
		armature.setScale(1);
		armature.setAnchorPoint(0.5, 0.5);
		armature.setPosition(640, 360);
		this.addChild(armature);

		this.setColor(cc.color.BLACK);
        this.setOpacity(20);
    }
});